home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / lib2to3 / fixes / fix_numliterals.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  1.2 KB  |  28 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Fixer that turns 1L into 1, 0755 into 0o755.
  5. '''
  6. from pgen2 import token
  7. from  import fixer_base
  8. from fixer_util import Number
  9.  
  10. class FixNumliterals(fixer_base.BaseFix):
  11.     
  12.     def match(self, node):
  13.         if not node.type == token.NUMBER and node.value.startswith('0'):
  14.             pass
  15.         return node.value[-1] in 'Ll'
  16.  
  17.     
  18.     def transform(self, node, results):
  19.         val = node.value
  20.         if val[-1] in 'Ll':
  21.             val = val[:-1]
  22.         elif val.startswith('0') and val.isdigit() and len(set(val)) > 1:
  23.             val = '0o' + val[1:]
  24.         
  25.         return Number(val, prefix = node.get_prefix())
  26.  
  27.  
  28.